<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
	method="html"
	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>

  <xsl:template match="/">
      	<table class = "usersTable">
      		<tr>
        		<th>Hour</th>
				<th>Sunday</th>
        		<th>Monday</th>
        		<th>Tuesday</th>
        		<th>Wednesday</th>
        		<th>Thursday</th>
        		<th>Friday</th>
        		<th>Saturday</th>
      		</tr>
        	<xsl:call-template name="for">
          	<xsl:with-param name="count" select="10"/>
        	</xsl:call-template>
      	</table>
  </xsl:template>

  <xsl:template name="for">
    <xsl:param name="i" select="0"/>
    <xsl:param name="count"/>

    <xsl:if test="$i &lt; $count">
      <tr>
        <td>
          <xsl:value-of select="concat($i + 8, ':00 - ', $i + 9, ':00')"/>
        </td>
         <xsl:call-template name="for2">
          <xsl:with-param name="count2" select="7"/>
          <xsl:with-param name="hour" select="$i"/>
        </xsl:call-template>
      </tr>

      <xsl:call-template name="for">
        <xsl:with-param name="i" select="$i + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>

  </xsl:template>
    <xsl:template name="for2">
    <xsl:param name="i2" select="0"/>
    <xsl:param name="hour"/>
    <xsl:param name="count2"/>

    <xsl:if test="$i2 &lt; $count2">
        <td>
          <xsl:value-of select="//Session[Day = $i2+1 and Start &lt;  $hour+9  and End &gt; ($hour +8)]/Course"/>
        </td>

      <xsl:call-template name="for2">
        <xsl:with-param name="i2" select="$i2 + 1"/>
        <xsl:with-param name="count2" select="$count2"/>
        <xsl:with-param name="hour" select="$hour"/>
      </xsl:call-template>
    </xsl:if>

  </xsl:template>

</xsl:stylesheet>
